<?php
class IndexAction extends BaseAction{
    public function index(){
        $this->display();
    }
    
    public function checkEnv()
    {
        load('pointer',THINK_PATH.'/Tpl/Autoindex');//载入探针函数
        $env_table = check_env();//根据当前函数获取当前环境
        echo $env_table;
    }
    public function option(){
    	 $this->display($_GET['type']);
    }
    
    //网站设置
    public function doOption(){
    	$dao = M("Option");
			foreach($_POST as $k=>$v){
      		$map['name'] = trim($k);
      		$dao->where($map)->delete();
	        $map['value'] = $v;
      		$dao->add($map);
      		unset($map);
      }

      //删除缓存
      S("site_option",null);

      $this->success("设置成功！");
    }
    
    public function cleancache(){
    	
    	$dirs	=	array(SITE_PATH.'home/Runtime',SITE_PATH.'admin/Runtime');
			//清理缓存
			foreach($dirs as $value)
			{
				$this->__rmdirr($value);
			
				echo "<div style='border:2px solid green; background:#f1f1f1; padding:20px;margin:20px;width:800px;font-weight:bold;color:green;text-align:center;'>\"".$value."\" have been cleaned clear! </div> <br /><br />";
			
				@mkdir($value,0777,true);
			
			}
    }
    
    private function __rmdirr($dirname) {

				if (!file_exists($dirname)) {
					return false;
				}
			
				if (is_file($dirname) || is_link($dirname)) {
					return unlink($dirname);
				}
			
				$dir = dir($dirname);
			
				while (false !== $entry = $dir->read()) {
			
					if ($entry == '.' || $entry == '..') {
						continue;
					}
			
					$this->__rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
				}
			
				$dir->close();
			
				return rmdir($dirname);
		}
    
    
}
?> 